﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace TraceThisItem.Domain.Initializers
{
    public class StatusNodeConfiguration : EntityTypeConfiguration<StatusNode>
    {
		public StatusNodeConfiguration()
        {
			HasKey(sn => sn.Id)
				.Property(sn => sn.Id)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

			Property(sn => sn.Name)
                .HasMaxLength(20)
                .IsRequired()
				.IsUnicode(false);

			HasRequired(sn => sn.Workflow)
				.WithMany(wf => wf.Nodes)
				.WillCascadeOnDelete();

			HasMany(sn => sn.NextStatusNodes)
				.WithMany();

        }
    }
}
